package com.holiday.springboot2.mapper;

import com.holiday.springboot2.domain.User;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserMapper {
    private static Map<Integer, User> UserMap = new HashMap<>();

    static {
        UserMap.put(1, new User(1, "1", "1"));
        UserMap.put(2, new User(2, "12", "12"));
        UserMap.put(3, new User(3, "13", "13"));
    }

    public User login(String username, String pwd) {
        User user = UserMap.get(Integer.valueOf(username));
        if (user == null) {
            return null;
        }
        if (user.getPwd().equals(pwd)) {
            return user;
        }
        return  null;
    }

}
